/**
  ******************************************************************************
  * @file           : measure.h
  * @brief          : Header for main.c file.
  *                   This file contains the common defines of the application.
  ******************************************************************************
  * @attention
  *
  ******************************************************************************
  */

#ifndef _MEASURE_H_
#define _MEASURE_H_

#include <stdint.h>
#include "storage.h"
#include "measbase.h"
#include "gv.h"

#define MEAS_QUE_LENGTH               20
#define MEAS_QUE_ITEMSIZE             sizeof(Meas_AdRawStru)

/* Exported constants --------------------------------------------------------*/
#define ADC_FREQ_HZ                   (100U)                           // ADC转换频率
#define MEASURE_FREQ_HZ               ADC_FREQ_HZ                      // 计量计算的频率
#define WADC_MAX                      (65535)                          // 重量AD最大值
#define M_DIV                         (100000000.0l)                    // 流量计算因子
#define F_MUL_0D1G_0D01S_TO_KGH       ((10.0 * 3600.0) / 1000.0)       // 0.1g/0.01s 转为 kg/h 的系数,系数为36
#define F_MUL_0D1G_0D01S_TO_TH        (F_MUL_0D1G_0D01S_TO_KGH/1000.0) // 0.1g/0.01s 转为 t/h 的系数,系数为0.036
#define ADBUF_DEEP                    (16)                             // AD原始数据缓存深度

#define AD_CODE_ACTUAL                0                                /* 内码实测 */
#define AD_CODE_GIVEN                 1                                /* 内码内给 */


extern void measure_init(GlobalVariablesStru *pgv);
extern void meas_timetick_init(void);
extern void measure_real_time(GlobalVariablesStru *pgv);
extern void measure_cycle(GlobalVariablesStru *pgv);
extern void meas_change_msm(Meas_MainStateMachineEnum mbst, GlobalVariablesStru *pgv);
extern uint64_t meas_division_indication(uint64_t src, uint8_t interval);
extern void meas_auto_zero(GlobalVariablesStru *pgv);
extern Meas_ReturnEnum meas_manual_zero(GlobalVariablesStru *pgv);
extern Meas_ReturnEnum meas_calibrate_shiwu(double flowrate_0d1g_0d01s, GlobalVariablesStru *pgv);
extern Meas_ReturnEnum meas_calibrate_guama(double flowrate_0d1g_0d01s, GlobalVariablesStru *pgv);
extern void meas_accrue(double flowrate_0d1g_0d01s, GlobalVariablesStru *pgv);

#endif /* _MEASURE_H_ */
